<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('登录设置')" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-weixinset-edit" th:object="${sysWeixinset}">
        <input id="id" th:value="${sysWeixinset.id}" type="hidden">
        <div class="wx" th:if="${sysWeixinset.id}==5" th:remove="tag">
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label">APPID：</label>
                    <div class="col-sm-8">
                        <input name="WAPPID" th:value="${data?.WAPPID}"  class="form-control" type="text">
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label">公众帐号APPSECRET：</label>
                    <div class="col-sm-8">
                        <input name="APPSECRET" th:value="${data?.APPSECRET}"  class="form-control" type="text">
                    </div>
                </div>
            </div>

        </div>
        <div class="wx" th:if="${sysWeixinset.id}==6" th:remove="tag">
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label">应用ID：</label>
                    <div class="col-sm-8">
                        <input name="AAPPID" th:value="${data?.AAPPID}" class="form-control" type="text">
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label">商户私钥：</label>
                    <div class="col-sm-8">
                        <input name="ALIKEY" th:value="${data?.ALIKEY}"  class="form-control" type="text">
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label">支付宝公钥：</label>
                    <div class="col-sm-8">
                        <input name="PALIKEY" th:value="${data?.PALIKEY}"  class="form-control" type="text">
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label">签名方式：</label>
                    <div class="col-sm-8">
                        <select name="SIGN" class="form-control">
                            <option  value="RSA" th:selected="${data?.SIGN}=='RSA'">RSA</option>
                            <option  value="RSA2" th:selected="${data?.SIGN}=='RSA2'">RSA2</option>
                        </select>
                    </div>
                </div>
            </div>
            <div class="ibox-content">
                <div class="alert alert-success">
                    请在支付宝开放平台申请接入应用

                    登录回调地址填写：http://您的域名/oauth/alipay/callback
                </div>

            </div>
        </div>
        <div class="col-xs-12">
            <div class="form-group">
                <label class="col-sm-3 control-label">状态：</label>
                <div class="col-sm-8">
                    <input type="checkbox" id="state" th:checked="${sysWeixinset.state == 1 ? true : false}">
                </div>
            </div>
        </div>

    </form>
</div>
<th:block th:include="include :: footer" />
<script th:inline="javascript">
    var prefix = ctx + "system/loginset";
    $("#form-weixinset-edit").validate({
        focusCleanup: true
    });

    function submitHandler() {
        if ($.validate.form()) {
            var data = $('#form-weixinset-edit').serializeArray();
            var jsonData = {}; // 创建一个空对象，用于存储 JSON 数据
            var jsonResult = [];
            console.log(data);
            // 将表单数据数组转换为 JSON 对象
            $.each(data, function(index, item) {
                jsonData[item.name] = item.value;
            });
            var jsonString = JSON.stringify(jsonData);
            var state = $("input[id='state']").is(':checked') == true ? 1 : 0;
            var id = $("#id").val();
            jsonResult.push({"name": "state", "value": state});
            jsonResult.push({"name": "value", "value": jsonString});
            jsonResult.push({"name": "id", "value": id});
            $.operate.save(prefix + "/edit", jsonResult);
        }
    }
</script>
</body>
</html>